package org.beasy.charts
{
	
	/**
	 * 货币单位对象
	 * 
	 * @author Marco
	 */	
	public class MoneyUnits
	{
		//--------------------------------------------------------------------------
		//
		//  Class constants
		//
		//--------------------------------------------------------------------------
		
		/**
		 * 原始单位
		 */		
		public static const NONE:String = "none";
		
		/**
		 * 百
		 */		
		public static const HUNDRED:String = "hundred";
		
		/**
		 * 千
		 */		
		public static const THOUSAND:String = "thousand";
		
		/**
		 * 万
		 */		
		public static const TEN_THOUSAND:String = "TEN_THOUSAND";
		
		/**
		 * 十万
		 */		
		public static const LAKH:String = "lakh";
		
		/**
		 * 百万
		 */		
		public static const MILLION:String = "million";
		
		//--------------------------------------------------------------------------
		//
		//  Constructor
		//
		//--------------------------------------------------------------------------
		
		public function MoneyUnits( label:String = null, unit:String = null )
		{
			super();
			_label = label;
			_unit = unit;
		}
		
		//--------------------------------------------------------------------------
		//
		//  Properties
		//
		//--------------------------------------------------------------------------
		
		/**
		 * @private
		 */		
		private var _label:String;
		
		/**
		 * @private
		 */		
		private var _unit:String;
		
		/**
		 * 单位所对应的标签:百,千,万...
		 */		
		public function set label(value:String):void
		{
			_label = value;
		}
		public function get label():String
		{
			return _label;
		}
		
		/**
		 * 要转换的单位:HUNDRED，THOUSAND，TEN_THOUSAND...
		 */		
		public function set unit(value:String):void
		{
			_unit = value;
		}
		public function get unit():String
		{
			return _unit;
		}
		
		/**
		 * @private
		 * 
		 * 根据代币单位计算
		 */		
		public static function formatByUnit( unitStr:String, num:Number ):Number
		{
			switch( unitStr )
			{
				case MoneyUnits.NONE :
					break;
				
				case MoneyUnits.HUNDRED :
					num /= 100;
					break;
				
				case MoneyUnits.THOUSAND :
					num /= 1000;
					break;
				
				case MoneyUnits.TEN_THOUSAND :
					num /= 10000;
					break;
				
				case MoneyUnits.LAKH :
					num /= 100000;
					break;
				
				case MoneyUnits.MILLION :
					num /= 1000000;
					break;
				
				default : break;
			}
			return num;
		}
		
	}
}